#!/bin/bash

latest=2022.2.2
latestcommit=75abed5c53f2d51e4afb678f91c8275d66f0ff42

if [ -z "$1" ]
then
  echo -e "\033[31m未指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "$latest" ]
then
  echo -e "\033[35m开始打包指定版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.2.2" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.2.2\033[0m"
  git reset --hard 75abed5c53f2d51e4afb678f91c8275d66f0ff42
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.1.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.1.1\033[0m"
  git reset --hard 94f6c556c23d2b9650864b30705471a111ee5b88
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
else
  echo -e "\033[31m无指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
fi
